package apIExercise.io;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 * 单个字节的复制
 */
public class CopyDemo {
    public static void main(String[] args) throws IOException {
        /*
        FileInputStream fis=new FileInputStream("./blr.jpg");
        FileOutputStream fos=new FileOutputStream("./blr_cp.jpg");
        int d;
        while ((d=fis.read())!=-1){
            fos.write(d);
        }
        System.out.println("复制完成！");
        fis.close();
        fos.close();
         */
        FileInputStream fis=new FileInputStream("blr.jpg");
        FileOutputStream fos=new FileOutputStream("./blr_01.jpg");
        long start=System.currentTimeMillis();
        int len;
        while ((len=fis.read())!=-1){
            fos.write(len);
        }
        long end=System.currentTimeMillis();
        System.out.println("复制成功！"+(end-start)+"ms");
        fis.close();
        fos.close();
    }

}
